package com.aspose.cells;

class zrw extends zbz {
   private Style d;
   private long e;
   private int f;
   byte[] a = null;
   private int g;

   zrw(Style var1) {
      this.d = var1;
      this.b(6);
      this.a();
      this.i();
   }

   private void a() {
      this.e = 4194303L;
      boolean var1 = false;
      if (this.d != null) {
         if (this.d.j()) {
            var1 = true;
            this.b();
         }

         if (this.d.k()) {
            var1 = true;
            this.c();
            this.b(this.d() + 118);
         }

         if (this.d.l()) {
            ;
         }

         if (this.d.m()) {
            var1 = true;
            this.g();
            this.b(this.d() + 8);
         }

         if (this.d.n()) {
            var1 = true;
            this.h();
            this.b(this.d() + 4);
         }

         if (this.d.o()) {
            ;
         }
      }

      if (!var1) {
         this.e = 0L;
      }

   }

   private void b() {
      this.e |= 33554432L;
      this.e &= -524289L;
      String var1 = this.d.s();
      if (var1 != null && !"".equals(var1)) {
         this.a = zco.a(var1);
         this.f |= 1;
         this.b(this.d() + (short)(5 + this.a.length));
      } else {
         this.b(this.d() + 2);
      }

   }

   private void c() {
      this.e |= 67108864L;
   }

   private void g() {
      this.e |= 268435456L;
      if (this.d.isModified(2)) {
         this.e &= -1025L;
      }

      if (this.d.isModified(3)) {
         this.e &= -2049L;
      }

      if (this.d.isModified(4)) {
         this.e &= -4097L;
      }

      if (this.d.isModified(5)) {
         this.e &= -8193L;
      }

   }

   private void h() {
      this.e |= 536870912L;
      if (this.d.isModified(33)) {
         this.e &= -65537L;
      }

      if (this.d.isModified(34)) {
         this.e &= -131073L;
      }

      if (this.d.isModified(35)) {
         this.e &= -262145L;
      }

   }

   private void i() {
      this.c = new byte[this.d()];
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.e), 0, this.c, 0, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.f), 0, this.c, 4, 2);
      if (this.d != null && (this.e & 4294967295L) != 0L) {
         this.g = 6;
         if (this.d.j()) {
            this.j();
         }

         if (this.d.k()) {
            this.k();
         }

         if (this.d.l()) {
            ;
         }

         if (this.d.m()) {
            this.l();
         }

         if (this.d.n()) {
            this.m();
         }

         if (this.d.o()) {
            ;
         }

      }
   }

   private void j() {
      if (this.a != null) {
         String var1 = this.d.s();
         System.arraycopy(com.aspose.cells.b.a.zc.a(5 + this.a.length), 0, this.c, this.g, 2);
         this.g += 2;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1.length()), 0, this.c, this.g, 2);
         if (var1.length() != this.a.length) {
            this.c[this.g + 2] = 1;
         }

         this.g += 3;
         System.arraycopy(this.a, 0, this.c, this.g, this.a.length);
         this.g += this.a.length;
      } else {
         this.c[this.g + 1] = (byte)(this.d.r() == -1 ? 0 : this.d.r());
         this.g += 2;
      }

   }

   private void k() {
      int var1;
      for(var1 = 0; var1 < 64; ++var1) {
         this.c[this.g + var1] = 0;
      }

      if (this.d.isModified(12)) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(this.d.getFont().getSize() * 20), 0, this.c, this.g + 64, 4);
      } else {
         this.c[this.g + 64] = -1;
         this.c[this.g + 65] = -1;
         this.c[this.g + 66] = -1;
         this.c[this.g + 67] = -1;
      }

      this.c[this.g + 68] |= (byte)(this.d.getFont().isItalic() ? 2 : 0);
      this.c[this.g + 68] |= (byte)(this.d.getFont().isStrikeout() ? 128 : 0);
      if (this.d.isModified(17)) {
         var1 = this.d.getFont().isBold() ? 700 : 400;
         System.arraycopy(com.aspose.cells.b.a.zc.a((short)var1), 0, this.c, this.g + 72, 2);
      } else {
         this.c[this.g + 72] = -1;
         this.c[this.g + 73] = -1;
      }

      byte var6 = -1;
      if (this.d.isModified(23)) {
         if (this.d.getFont().isSubscript()) {
            var6 = 2;
         } else if (this.d.getFont().isSuperscript()) {
            var6 = 1;
         }
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var6), 0, this.c, this.g + 74, 2);
      byte var2 = -1;
      if (this.d.isModified(19)) {
         switch(this.d.getFont().getUnderline()) {
         case 1:
            var2 = 1;
            break;
         case 2:
            var2 = 2;
            break;
         case 3:
            var2 = 33;
            break;
         case 4:
            var2 = 34;
         }
      }

      this.c[this.g + 76] = var2;

      int var3;
      for(var3 = 0; var3 < 3; ++var3) {
         this.c[this.g + 77 + var3] = 0;
      }

      var3 = -1;
      if (this.d.isModified(16)) {
         var3 = this.d.a((zakp)this.d.getFont().b, (int)32767);
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var3), 0, this.c, this.g + 80, 4);

      int var4;
      for(var4 = 0; var4 < 4; ++var4) {
         this.c[this.g + 84 + var4] = 0;
      }

      var4 = !this.d.isModified(17) && !this.d.isModified(18) ? 154 : 152;
      if (this.d.isModified(20)) {
         var4 &= -129;
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var4), 0, this.c, this.g + 88, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.d.isModified(23) ? 0 : 1), 0, this.c, this.g + 92, 4);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.d.isModified(19) ? 0 : 1), 0, this.c, this.g + 96, 4);
      if (!this.d.isModified(17)) {
         this.c[this.g + 100] = 1;
         this.c[this.g + 101] = 0;
         this.c[this.g + 102] = 0;
         this.c[this.g + 103] = 0;
      } else {
         this.c[this.g + 100] = 0;
         this.c[this.g + 101] = 0;
         this.c[this.g + 102] = 0;
         this.c[this.g + 103] = 0;
      }

      for(int var5 = 0; var5 < 12; ++var5) {
         this.c[this.g + 104 + var5] = 0;
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a((short)1), 0, this.c, this.g + 116, 2);
      this.g += 118;
   }

   private void l() {
      int var1 = 0;
      int var2 = 0;
      boolean var3 = true;
      int var4;
      if (this.d.isModified(2)) {
         var1 |= this.d.getBorders().getByBorderType(1).getLineStyle();
         var4 = this.d.a((zakp)this.d.getBorders().getByBorderType(1).a, (int)64);
         var2 |= var4;
      }

      if (this.d.isModified(3)) {
         var1 |= this.d.getBorders().getByBorderType(2).getLineStyle() << 4;
         var4 = this.d.a((zakp)this.d.getBorders().getByBorderType(2).a, (int)64);
         var2 |= var4 << 7;
      }

      if (this.d.isModified(4)) {
         var1 |= this.d.getBorders().getByBorderType(4).getLineStyle() << 8;
         var4 = this.d.a((zakp)this.d.getBorders().getByBorderType(4).a, (int)64);
         var2 |= var4 << 16;
      }

      if (this.d.isModified(5)) {
         var1 |= this.d.getBorders().getByBorderType(8).getLineStyle() << 12;
         var4 = this.d.a((zakp)this.d.getBorders().getByBorderType(8).a, (int)64);
         var2 |= var4 << 23;
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var1), 0, this.c, this.g, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, this.c, this.g + 2, 4);
      this.c[this.g + 6] = 0;
      this.c[this.g + 7] = 0;
      this.g += 8;
   }

   private void m() {
      int var1 = 0;
      byte var2 = 0;
      if (this.d.isModified(33)) {
         var1 |= this.d.getPattern() << 10;
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var1), 0, this.c, this.g, 2);
      boolean var3 = false;
      boolean[] var4 = new boolean[]{var3};
      int var5 = this.d.b.b(this.d.e(), 64, var4);
      var3 = var4[0];
      int var6 = var2 | var5;
      var3 = false;
      var4 = new boolean[]{var3};
      var5 = this.d.a.b(this.d.e(), 65, var4);
      var3 = var4[0];
      var6 |= var5 << 7;
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var6), 0, this.c, this.g + 2, 2);
      this.g += 4;
   }
}
